﻿using MediatR;
using System.Reflection.Metadata;

namespace HelloMediatR.Handler
{
    public class PingHandler : IRequestHandler<Ping, string>
    {
        private readonly IMediator _mediator;

        public PingHandler(IMediator mediator) {
            _mediator = mediator;
        }
       

        public async Task<string> Handle(Ping request, CancellationToken cancellationToken)
        {
            await _mediator.Publish(new PingN());
            return "PongHandle";
        }

        //async Task<string> IRequestHandler<Ping, string>.Handle(Ping request, CancellationToken cancellationToken)
        //{
        //    await _mediator.Publish(new PingN());
        //    return "PongIHandle";
        //}
    }

    //public class PingHandlerV1 : IRequestHandler<Ping, string>
    //{
    //    public async Task<string> Handle(Ping request, CancellationToken cancellationToken)
    //    {
    //        return "Pong1";
    //    }
    //}

}
